﻿Imports PTIC_GestionBDD
Imports Actuariat
Imports PTIC_Util
Imports PTIC_Util.gestionCalculs
Imports Actuariat.comptes
Imports System.ComponentModel
Imports System.Collections
Imports System.Data

Namespace moteurTauxGaranti2

#Region "Les résultats"
    Partial Public Class Moteur_Methode2
        Public Class resultatsMoteur2
            Protected _TableEntreeEnrichie As DataTable
            Protected _TableProjectionGen1Detaillee As DataTable
            Protected _ProjectionGen1Annuelle As projectionAnneesReelles
            Protected _ProjAnneeReelleMax As Integer
            Protected _ProjectionGenNAnnuelle As projectionAnneesReelles

            Protected _ResultatsCRTVie As comptes.compteTechniqueVie_V2.resultatsCRTVie
            Protected _ResultatsCRTNonVie As comptes.compteTechniqueNonVie_V2.resultatsCRTNonVie
            Protected _ResultatsCRNonTechnique As comptes.compteNonTechnique_V2.resultatsCRNonTechnique
            Protected _ResultatsBesoinsFdsPropres As comptes.compteBesoinsFondsPropres_V2.resultatsCompteBesoinsFondsPropres
            Protected _ResultatsBilan As comptes.bilan_V2.resultatsBilan
            Protected _ResultatsTresorerie As comptes.compteTresorerie_V2.resultatsCompteTreso
            Protected _ResultatsIndicateurs As comptes.indicateurs_V2.resultatsIndicateurs

            Public Property TableEntreeEnrichie() As DataTable
                Get
                    Return _TableEntreeEnrichie
                End Get
                Set(ByVal value As DataTable)
                    If Not _TableEntreeEnrichie Is Nothing Then
                        If _TableEntreeEnrichie.Equals(value) Then
                            Exit Property
                        End If
                    End If
                    _TableEntreeEnrichie = value
                    RaiseEvent tableEntreeEnrichie_hasChanged(Me, Nothing)
                End Set
            End Property
            Public Property TableProjectionGen1Detaillee() As DataTable
                Get
                    Return _TableProjectionGen1Detaillee
                End Get
                Set(ByVal value As DataTable)
                    If Not _TableProjectionGen1Detaillee Is Nothing Then
                        If _TableProjectionGen1Detaillee.Equals(value) Then
                            Exit Property
                        End If
                    End If
                    _TableProjectionGen1Detaillee = value
                    RaiseEvent tableProjectionGen1Detaillee_hasChanged(Me, Nothing)
                End Set
            End Property
            Public Property ProjectionGen1Annuelle() As projectionAnneesReelles
                Get
                    Return _ProjectionGen1Annuelle
                End Get
                Set(ByVal value As projectionAnneesReelles)
                    If Not _ProjectionGen1Annuelle Is Nothing Then
                        If _ProjectionGen1Annuelle.Equals(value) Then
                            Exit Property
                        End If
                    End If
                    _ProjectionGen1Annuelle = value
                    RaiseEvent ProjectionGen1Annuelle_hasChanged(Me, Nothing)
                End Set
            End Property
            Public Property ProjectionGenNAnnuelle() As projectionAnneesReelles
                Get
                    Return _ProjectionGenNAnnuelle
                End Get
                Set(ByVal value As projectionAnneesReelles)
                    If Not _ProjectionGenNAnnuelle Is Nothing Then
                        If _ProjectionGenNAnnuelle.Equals(value) Then
                            Exit Property
                        End If
                    End If
                    _ProjectionGenNAnnuelle = value
                    RaiseEvent ProjectionGenNAnnuelle_hasChanged(Me, Nothing)
                End Set
            End Property
            Public Property ProjAnneeReelleMax() As Integer
                Get
                    Return _ProjAnneeReelleMax
                End Get
                Set(ByVal value As Integer)
                    If Not _ProjAnneeReelleMax = value Then
                        _ProjAnneeReelleMax = value
                        RaiseEvent ProjAnneeRelleMax_hasChanged(Me, Nothing)
                    End If
                End Set
            End Property

            Public Property compteCRTVie() As comptes.compteTechniqueVie_V2.resultatsCRTVie
                Get
                    Return _ResultatsCRTVie
                End Get
                Set(ByVal value As comptes.compteTechniqueVie_V2.resultatsCRTVie)
                    If Not value.Equals(_ResultatsCRTVie) Then
                        _ResultatsCRTVie = value
                        RaiseEvent compteCRTvie_hasChanged(Me, Nothing)
                    End If
                End Set
            End Property
            Public Property compteCRTNonVie() As comptes.compteTechniqueNonVie_V2.resultatsCRTNonVie
                Get
                    Return _ResultatsCRTNonVie
                End Get
                Set(ByVal value As comptes.compteTechniqueNonVie_V2.resultatsCRTNonVie)
                    If Not value.Equals(_ResultatsCRTNonVie) Then
                        _ResultatsCRTNonVie = value
                        RaiseEvent compteCRTNonVie_hasChanged(Me, Nothing)
                    End If
                End Set
            End Property
            Public Property compteCRNonTechnique() As comptes.compteNonTechnique_V2.resultatsCRNonTechnique
                Get
                    Return _ResultatsCRNonTechnique
                End Get
                Set(ByVal value As comptes.compteNonTechnique_V2.resultatsCRNonTechnique)
                    If Not value.Equals(_ResultatsCRNonTechnique) Then
                        _ResultatsCRNonTechnique = value
                        RaiseEvent compteCRTNonTechnique_hasChanged(Me, Nothing)
                    End If
                End Set
            End Property
            Public Property compteBesoinsFdsPropres() As comptes.compteBesoinsFondsPropres_V2.resultatsCompteBesoinsFondsPropres
                Get
                    Return _ResultatsBesoinsFdsPropres
                End Get
                Set(ByVal value As comptes.compteBesoinsFondsPropres_V2.resultatsCompteBesoinsFondsPropres)
                    If Not value.Equals(_ResultatsBesoinsFdsPropres) Then
                        _ResultatsBesoinsFdsPropres = value
                        RaiseEvent compteBesoinsFdsPropres_hasChanged(Me, Nothing)
                    End If
                End Set
            End Property
            Public Property compteBilan() As comptes.bilan_V2.resultatsBilan
                Get
                    Return _ResultatsBilan
                End Get
                Set(ByVal value As comptes.bilan_V2.resultatsBilan)
                    If Not value.Equals(_ResultatsBilan) Then
                        _ResultatsBilan = value
                        RaiseEvent compteBilan_hasChanged(Me, Nothing)
                    End If
                End Set
            End Property
            Public Property compteTresorerie() As compteTresorerie_V2.resultatsCompteTreso
                Get
                    Return _ResultatsTresorerie
                End Get
                Set(ByVal value As compteTresorerie_V2.resultatsCompteTreso)
                    If Not value.Equals(_ResultatsTresorerie) Then
                        _ResultatsTresorerie = value
                        RaiseEvent compteTresorerie_hasChanged(Me, Nothing)
                    End If
                End Set
            End Property
            Public Property compteIndicateur() As comptes.indicateurs_V2.resultatsIndicateurs
                Get
                    Return _ResultatsIndicateurs
                End Get
                Set(ByVal value As comptes.indicateurs_V2.resultatsIndicateurs)
                    If Not value.Equals(_ResultatsIndicateurs) Then
                        _ResultatsIndicateurs = value
                        RaiseEvent compteIndicateur_hasChanged(Me, Nothing)
                    End If
                End Set
            End Property
            Public Sub clear()
                _TableEntreeEnrichie = Nothing
                _TableProjectionGen1Detaillee = Nothing
                _ProjectionGen1Annuelle = Nothing
                _ProjAnneeReelleMax = 0
                _ProjectionGenNAnnuelle = Nothing
                _ResultatsCRTVie = Nothing
                _ResultatsCRTNonVie = Nothing
                _ResultatsCRNonTechnique = Nothing
                _ResultatsBesoinsFdsPropres = Nothing
                _ResultatsBilan = Nothing
                _ResultatsTresorerie = Nothing
                _ResultatsIndicateurs = Nothing
            End Sub

            Public Event tableEntreeEnrichie_hasChanged As resultatsMoteur2EventHandler
            Public Event tableProjectionGen1Detaillee_hasChanged As resultatsMoteur2EventHandler
            Public Event ProjectionGen1Annuelle_hasChanged As resultatsMoteur2EventHandler
            Public Event ProjectionGenNAnnuelle_hasChanged As resultatsMoteur2EventHandler
            Public Event ProjAnneeRelleMax_hasChanged As resultatsMoteur2EventHandler
            Public Event compteCRTvie_hasChanged As resultatsMoteur2EventHandler
            Public Event compteCRTNonVie_hasChanged As resultatsMoteur2EventHandler
            Public Event compteCRTNonTechnique_hasChanged As resultatsMoteur2EventHandler
            Public Event compteBesoinsFdsPropres_hasChanged As resultatsMoteur2EventHandler
            Public Event compteBilan_hasChanged As resultatsMoteur2EventHandler
            Public Event compteTresorerie_hasChanged As resultatsMoteur2EventHandler
            Public Event compteIndicateur_hasChanged As resultatsMoteur2EventHandler

            Public Delegate Sub resultatsMoteur2EventHandler(ByVal sender As Object, ByVal e As EventArgs)
        End Class
    End Class
#End Region

#Region "Scénario central"
    Public Class scenarioCentralMoteur2
        Inherits CalculIndividuel
        Implements IObserver

        Protected _moteur As Moteur_Methode2
        Protected _univers As UniversOMANE


        Public Sub New(ByVal moteur As Moteur_Methode2, ByVal univers As UniversOMANE)
            _moteur = moteur
            _univers = univers
            _resultats = New Moteur_Methode2.resultatsMoteur2
        End Sub

        Public Overloads Property resultats() As Moteur_Methode2.resultatsMoteur2
            Get
                Return _resultats
            End Get
            Set(ByVal value As Moteur_Methode2.resultatsMoteur2)
                _resultats = value
            End Set
        End Property

        Protected Overrides Sub procedureCalcul()
            'Si le moteur de calcul n'est pas à jour pour les paramètres et le traitement en entrée
            'actuellement renseignés
            '   - On relance les calculs
            '   - Sinon, on met à jour directement les comptes
            ''resultats.clear()
            ''_univers.listeTraitements.getTraitEntreeModeleTxGar.invalideAll()
            _moteur.CalculeInit()
            _moteur.Calculer()
            _moteur.CalculeCloture()
        End Sub

    End Class
#End Region

#Region "Le coeur"
    Partial Public Class Moteur_Methode2
        Inherits baseMoteur
        Implements IObserver

        Public Enum TypeCalcul
            ScenarioCentral
            Simulations
        End Enum

#Region "Variables de classe"

        Protected _tablesTravail As tablesTravail
        Protected _listeParametres As ParametresList
        Protected _capitauxInitiaux As gestionParametreGlobal
        Protected _nbPretsAssuGen1 As gestionParametreGlobal
        Protected _nbGenProj As Integer
        Protected _croissPopAssuNb As Double
        Protected _croissCapIni As Double
        Protected _filtreSegments As Integer
        Protected _filtreGeneration As Integer
        Protected _nbSegments As Integer

        Protected _moteurEcheancier As Moteur_Echeancier
        Protected _comptes As ComptesMoteur2
        Private _fonctionCalculDataTable As fonctionCalculMoteur2

        Protected _scenarioCentral As scenarioCentralMoteur2
        Protected _simulations As simulationsMoteur2
        Protected _TypeCalcul As TypeCalcul

#End Region

#Region "Constructeur"
        Public Sub New(ByVal nom As String, _
                       ByVal coll_Param As ParametresList, _
                       ByVal universBDD As UniversOMANE)
            MyBase.New(nom, coll_Param, universBDD)
            _resultats = New resultatsMoteur2
            _moteurEcheancier = New Moteur_Echeancier("moteurMethode2_Echeancier", coll_Param, universBDD)
            _comptes = New ComptesMoteur2()
            _comptes.anneePremiereGeneration = 2010
            _etatExecDataTable = New etatCalcul
            _fonctionCalculDataTable = New fonctionCalculMoteur2(typeRecalcul.SurOrdre, Me, _etatExecDataTable)
            _fonctionCalculDataTable.ajouteObserver(Me)
            _scenarioCentral = New scenarioCentralMoteur2(Me, universBDD)
            _simulations = New simulationsMoteur2(Me)
            _TypeCalcul = TypeCalcul.ScenarioCentral
            defaut()
        End Sub
        Public Sub defaut()

            _tablesTravail = New tablesTravail(_univers)

            _capitauxInitiaux = New gestionParametreGlobal(DirectCast(_univers, UniversOMANE).listeTraitements.getTraitSumCapInit)
            AddHandler _capitauxInitiaux.hasChanged, AddressOf paramGlobalMoteur2_hasChanged
            capitauxInitiaux.valeurPerso = 1000000
            capitauxInitiaux.methodeCalcul = gestionParametreGlobal.typeCalcul.Personnalisé

            _nbPretsAssuGen1 = New gestionParametreGlobal(DirectCast(_univers, UniversOMANE).listeTraitements.getTraitNbPretsXassu)
            AddHandler _nbPretsAssuGen1.hasChanged, AddressOf paramGlobalMoteur2_hasChanged
            nbPretsAssuGen1.valeurPerso = 1000
            nbPretsAssuGen1.methodeCalcul = gestionParametreGlobal.typeCalcul.Personnalisé

            _nbGenProj = 1
            _croissPopAssuNb = 0.05
            _croissCapIni = 0
            _filtreSegments = 0
            _filtreGeneration = 0

        End Sub
#End Region

#Region "Propriétés"

        ''' <summary>
        ''' Etat d'exécution de la fonction de calcul de la dataTable du moteur
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        ''' 
        Public Overloads ReadOnly Property etatExecDataTable() As valueEtatCalcul
            Get
                Return _fonctionCalculDataTable.etatCalcul
            End Get
        End Property

        ''' <summary>
        ''' Tables de travail utilisées par le moteur (table de mortalité, INCAP/INVAL)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property tablesDeTravail() As tablesTravail
            Get
                Return _tablesTravail
            End Get
        End Property
        ''' <summary>
        ''' Le nombre de segments disponibles dans la segmentation
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property nbSegments() As Integer
            Get
                Return _nbSegments
            End Get
        End Property

        ''' <summary>
        ''' Les comptes résultats du moteur de calcul 2
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property Comptes() As ComptesMoteur2
            Get
                Return _comptes
            End Get
        End Property
        ''' <summary>
        ''' Résultats de l'exécution du moteur de calcul
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Overloads ReadOnly Property Resultats() As resultatsMoteur2
            Get
                Return _resultats
            End Get
        End Property

        ''' <summary>
        ''' L'objet gérant les calculs du scénario central
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property scenarioCentral() As scenarioCentralMoteur2
            Get
                Return _scenarioCentral
            End Get
        End Property
        ''' <summary>
        ''' L'objet gérant les calculs des simulations
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public ReadOnly Property Simulations() As simulationsMoteur2
            Get
                Return _simulations
            End Get
        End Property

        Public Property TypeScenarioCalcule() As TypeCalcul
            Get
                Return _TypeCalcul
            End Get
            Friend Set(ByVal value As TypeCalcul)
                _TypeCalcul = value
            End Set
        End Property

#Region "Paramètres communs aux modèles 1 et 2"
        Public Property listeParametres() As ParametresList
            Get
                Return _listeParametres
            End Get
            Set(ByVal value As ParametresList)
                If Not value Is _listeParametres Then
                    If Not _listeParametres Is Nothing Then
                        For Each param As baseParametre In _listeParametres.Values
                            If param.methode_Cal(1) Then param.retireObserver(_fonctionCalculDataTable)
                        Next
                    End If
                    If Not value Is Nothing Then
                        For Each param As baseParametre In value.Values
                            If param.methode_Cal(1) Then param.ajouteObserver(_fonctionCalculDataTable)
                        Next
                    End If
                    _listeParametres = value
                End If
            End Set
        End Property
#End Region
#Region "Filtres à effectuer pour les projections"
        ''' <summary>
        ''' Le filtre retenu pour le segment affiché
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property filtreSegment() As Integer
            Get
                Return _filtreSegments
            End Get
            Set(ByVal value As Integer)
                If value <> _filtreSegments Then
                    _filtreSegments = value
                    notifieChangement(Me, notification.ModifFiltreSegments)
                End If
            End Set
        End Property
        ''' <summary>
        ''' Le filtre retenu pour la génération
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property filtreGeneration() As Integer
            Get
                Return _filtreGeneration
            End Get
            Set(ByVal value As Integer)
                If value <> _filtreGeneration Then
                    _filtreGeneration = value
                    notifieChangement(Me, notification.ModifFiltreGenerations)
                End If
            End Set
        End Property
#End Region
#Region "Paramètres spécifiques au moteur 2"
        Public ReadOnly Property capitauxInitiaux() As gestionParametreGlobal
            Get
                Return _capitauxInitiaux
            End Get
        End Property
        Public ReadOnly Property nbPretsAssuGen1() As gestionParametreGlobal
            Get
                Return _nbPretsAssuGen1
            End Get
        End Property
        Public Property nbGenProj() As Integer
            Get
                Return _nbGenProj
            End Get
            Set(ByVal value As Integer)
                If value <> _nbGenProj Then
                    _nbGenProj = value
                    notifieChangement(Me, notification.ModifNbGenerationsProjetees)
                End If
            End Set
        End Property
        Public Property croissPopAssuNb() As Double
            Get
                Return _croissPopAssuNb
            End Get
            Set(ByVal value As Double)
                If value <> _croissPopAssuNb Then
                    _croissPopAssuNb = value
                    notifieChangement(Me, notification.ModifCroissNbPrets)
                End If
            End Set
        End Property
        Public Property croissCapIni() As Double
            Get
                Return _croissCapIni
            End Get
            Set(ByVal value As Double)
                If value <> _croissCapIni Then
                    _croissCapIni = value
                    notifieChangement(Me, notification.ModifCroissCImoyens)
                End If
            End Set
        End Property
#End Region
#End Region

#Region "Méthodes de lancement des calculs"

        Public Sub CalculeInit()
            Resultats.clear()
            'Faire les jointures avec les paramètres déclinés pour récupérer les valeurs courantes
            Dim parametres_decl As Hashtable
            Dim parametres_uniq As Hashtable
            Dim selMedic As Double()
            listeParametres.MAJ_CollParamDeclUniq(2)
            parametres_decl = listeParametres.getParamDecl
            parametres_uniq = listeParametres.getParamUniq
            For Each p As IParamV2 In parametres_uniq.Values
                p.setValeurEnCoursAsObject(p.getValeurUniqueAsObject)
                If p.nom = nomSel_medic Then
                    selMedic = p.getValeurEnCoursAsObject
                End If
            Next
            Dim TableEntree As DataTable = DirectCast(Me.univers, UniversOMANE).listeTraitements.getTraitEntreeModeleTxGar.execute_DataTable(True).Copy
            enrichieDataTableEntree(TableEntree)
            Resultats.TableEntreeEnrichie = TableEntree
            'Paramétrage de toutes les relations liées à la mise à jour des paramètres déclinés
            CType(_univers, UniversOMANE).ParamRelationsV2(parametres_decl, TableEntree)
        End Sub
        Public Sub Calculer()
            If _fonctionCalculDataTable Is Nothing Then Exit Sub
            If _fonctionCalculDataTable.etatCalcul <> valueEtatCalcul.A_JOUR Then _fonctionCalculDataTable.Calculer()
            _fonctionCalculDataTable.ModeRecalcul = typeRecalcul.Automatique
        End Sub
        Public Sub CalculeCloture()
            Dim parametres_decl As Hashtable = listeParametres.getParamDecl
            CType(_univers, UniversOMANE).SupprParamRelations(parametres_decl)
        End Sub

        Public Sub validePossibiliteCalcule()
            _fonctionCalculDataTable.EstCalculable()
        End Sub
        Public Sub invalidePossibiliteCalcule()
            _fonctionCalculDataTable.EstNonCalculable()
        End Sub
        Public Overrides Sub invalideAll()
            notifieChangement(Me, notification.InvaliderCalculs)
        End Sub

#End Region

#Region "Méthodes d'exécution héritées de la classe traitement"
        Public Overrides Function execute_BDD() As String
            Return Nothing
        End Function
        Public Overrides Function execute_DataTable(ByVal stockageBDDlocale As Boolean) As System.Data.DataTable
            Return Nothing
        End Function
        Public Overrides Function execute_DataTableToDgv(ByVal stockageBDDlocale As Boolean, ByVal dgv As System.Windows.Forms.DataGridView) As System.Data.DataTable
            Return Nothing
        End Function
#End Region

#Region "Rafraichissements"
        Public Sub paramGlobalMoteur2_hasChanged(ByVal sender As Object, _
                                                 ByVal e As gestionParametreGlobal.eventHandler)

            If sender Is _capitauxInitiaux Then
                notifieChangement(Me, notification.ModifCapitauxInitiaux)
            ElseIf sender Is _nbPretsAssuGen1 Then
                notifieChangement(Me, notification.ModifNbPretsInitiaux)
            End If

        End Sub
        Public Sub traitEntree_EtatAChange(ByVal sender As Object, ByVal e As Traitement.notifTraitement)
            If e.Changement = Traitement.notifTraitement.natureChangement.etatCalculDataTableAchange Then
                If CType(sender, RequeteBDD).etatExecDataTable = valueEtatCalcul.A_MAJ Then
                    notifieChangement(Me, notification.InvaliderCalculs)
                End If
            End If
        End Sub
        Public Overrides Function actualise(ByVal sender As Object, ByVal notification As Object) As PTIC_Util.resultatValidationContraintes
            MyBase.actualise(sender, notification)
            If TypeOf sender Is Segmentation Then
                Dim notif As Segmentation.notification = CType(notification.notification, Segmentation.notification)
                actualiseFromSegmentation(sender, notif)

            ElseIf TypeOf sender Is IFonctionCalcul Then
                Dim notif As FonctionCalcul.notification = notification
                If notif = FonctionCalcul.notification.ApresModifEtatCalcul Then
                    notifieChangement(Me, Moteur_Methode2.notification.EtatCalculDataTableAChange)
                End If

            End If

            Return Nothing

        End Function
        Public Function actualiseFromSegmentation(ByVal sender As Segmentation, ByVal notif As Segmentation.notification)
            If notif = Segmentation.notification.ModifSegmentsRetenus Then
                Dim table As DataTable = CType(_univers, UniversOMANE).listeTraitements.getTraitReqSegmentation.execute_DataTable(True)
                If Not table Is Nothing Then
                    _nbSegments = table.Rows.Count
                Else
                    _nbSegments = 0
                End If
                'Générer un évènement indiquant que le nombre de segments a changé
                notifieChangement(Me, notification.ModifSegmentationRetenue)
            End If
            Return Nothing
        End Function
#End Region

#Region "Structures englobées"

#Region "Notifications"
        Public Enum notification
            ModifFiltreSegments
            ModifFiltreGenerations
            ModifSegmentationRetenue
            ModifNbGenerationsProjetees
            ModifCapitauxInitiaux
            ModifNbPretsInitiaux
            ModifCroissCImoyens
            ModifCroissNbPrets
            CalculProjectionsDetailleesGen1
            CalculProjectionsAnnuellesGen1
            CalculProjectionAnnuellesGenN
            CalculComptes
            EtatCalculDataTableAChange
            InvaliderCalculs
        End Enum
#End Region

#Region "Paramétrage"
        Protected Structure parametreEntreeProjection
            Dim nbPeriode As Integer
            Dim ageInitial As Double
            Dim capitalInitial As Double
            Dim txNominalPeriode As Double
            Dim nbInitialAssures As Double
            Dim txRembAntiPeriode As Double
            Dim txEntreeINCINVmois As Double
            Dim txTaxeINCINV As Double
            Dim txFG As Double
            Dim txTechPeriode As Double
            Dim tarifINCINVPeriode As Double
            Dim tarifDCPeriode As Double
            Dim ageFinINCINV As Double
            Dim ageFinDC As Double
            Dim txComPartenaire As Double
            Dim abtMNO As Double
            Dim abtPerteRevenus As Double
            Dim majSinDC As Double
            Dim majSinINCINV As Double
            Dim tableMort As tableMortalite
            Dim tableMaintienINCINV As tableMaintienINCAPINVAL
            Dim selectionMedicale As Double()
            Dim presenceSelectionMedicale As Boolean
        End Structure
        Public Class tablesTravail
            Protected _univers As UniversOMANE
            Protected _tableMortH As tableMortalite
            Protected _tableMortF As tableMortalite
            Protected _tableMaintienINCINV As tableMaintienINCAPINVAL
            Public Sub New(ByVal universOMANE As UniversOMANE)
                _univers = universOMANE
            End Sub
            Public Sub setTableMortaliteH(ByVal nomTableMortaliteH As String)
                Dim aMAJ As Boolean = True
                If Not _tableMortH Is Nothing Then
                    If nomTableMortaliteH = _tableMortH.nom Then
                        aMAJ = False
                    End If
                End If
                If aMAJ Then
                    Dim tbleMortH As DataTable = _univers.getTableBDDReferentiel("TableMortalite", nomTableMortaliteH).execute_DataTable(False)
                    Dim tableauMortalite(tbleMortH.Rows.Count, 1) As Double, i As Integer = 0
                    For Each r As DataRow In tbleMortH.Rows
                        tableauMortalite(i, 0) = r(0)
                        tableauMortalite(i, 1) = 1 - (1 - r(1)) ^ (1 / 12)
                        i = i + 1
                    Next
                    _tableMortH = New Actuariat.tableMortalite(tableauMortalite, nomTableMortaliteH)
                End If
            End Sub
            Public Sub setTableMortaliteH(ByVal tbleMortH As DataTable, ByVal nomTableMortaliteH As String)
                Dim aMAJ As Boolean = True
                If Not _tableMortH Is Nothing Then
                    If nomTableMortaliteH = _tableMortH.nom Then
                        aMAJ = False
                    End If
                End If
                If aMAJ Then
                    Dim tableauMortalite(tbleMortH.Rows.Count, 1) As Double, i As Integer = 0
                    For Each r As DataRow In tbleMortH.Rows
                        tableauMortalite(i, 0) = r(0)
                        tableauMortalite(i, 1) = 1 - (1 - r(1)) ^ (1 / 12)
                        i = i + 1
                    Next
                    _tableMortH = New Actuariat.tableMortalite(tableauMortalite, nomTableMortaliteH)
                End If
            End Sub
            Public Sub setTableMortaliteF(ByVal nomTableMortaliteF As String)
                Dim aMAJ As Boolean = True
                If Not _tableMortF Is Nothing Then
                    If nomTableMortaliteF = _tableMortF.nom Then
                        aMAJ = False
                    End If
                End If
                If aMAJ Then
                    Dim tbleMortF As DataTable = _univers.getTableBDDReferentiel("TableMortalite", nomTableMortaliteF).execute_DataTable(False)
                    Dim tableauMortalite(tbleMortF.Rows.Count, 1) As Double, i As Integer = 0
                    For Each r As DataRow In tbleMortF.Rows
                        tableauMortalite(i, 0) = r(0)
                        tableauMortalite(i, 1) = 1 - (1 - r(1)) ^ (1 / 12)
                        i = i + 1
                    Next
                    _tableMortF = New Actuariat.tableMortalite(tableauMortalite, nomTableMortaliteF)
                End If
            End Sub
            Public Sub setTableMortaliteF(ByVal tbleMortF As DataTable, ByVal nomTableMortaliteF As String)
                Dim aMAJ As Boolean = True
                If Not _tableMortF Is Nothing Then
                    If nomTableMortaliteF = _tableMortF.nom Then
                        aMAJ = False
                    End If
                End If
                If aMAJ Then
                    Dim tableauMortalite(tbleMortF.Rows.Count, 1) As Double, i As Integer = 0
                    For Each r As DataRow In tbleMortF.Rows
                        tableauMortalite(i, 0) = r(0)
                        tableauMortalite(i, 1) = 1 - (1 - r(1)) ^ (1 / 12)
                        i = i + 1
                    Next
                    _tableMortF = New Actuariat.tableMortalite(tableauMortalite, nomTableMortaliteF)
                End If
            End Sub
            Public Sub setTableMaintienINCINV(ByVal nomTableMaintienINCINV As String)
                Dim aMAJ As Boolean = True
                If Not _tableMaintienINCINV Is Nothing Then
                    If nomTableMaintienINCINV = _tableMaintienINCINV.nom Then
                        aMAJ = False
                    End If
                End If
                If aMAJ Then
                    'Récupération de la table dans le référentiel
                    Dim tbleINCINV As DataTable = _univers.getTableBDDReferentiel("tableINCINV", nomTableMaintienINCINV).execute_DataTable(False)
                    Dim tableau_INCINV(tbleINCINV.Rows.Count - 1, tbleINCINV.Columns.Count - 1) As Double
                    For i As Integer = 0 To tbleINCINV.Rows.Count - 1
                        For j As Integer = 0 To tbleINCINV.Columns.Count - 1
                            tableau_INCINV(i, j) = tbleINCINV(i)(j)
                        Next
                    Next
                    _tableMaintienINCINV = New Actuariat.tableMaintienINCAPINVAL(tableau_INCINV, 18, 64, nomTableMaintienINCINV)
                End If
            End Sub
            Public Sub setTableMaintienINCINV(ByVal tbleINCINV As DataTable, ByVal nomTableMaintienINCINV As String)
                Dim aMAJ As Boolean = True
                If Not _tableMaintienINCINV Is Nothing Then
                    If nomTableMaintienINCINV = _tableMaintienINCINV.nom Then
                        aMAJ = False
                    End If
                End If
                If aMAJ Then
                    Dim tableau_INCINV(tbleINCINV.Rows.Count - 1, tbleINCINV.Columns.Count - 1) As Double
                    For i As Integer = 0 To tbleINCINV.Rows.Count - 1
                        For j As Integer = 0 To tbleINCINV.Columns.Count - 1
                            tableau_INCINV(i, j) = tbleINCINV(i)(j)
                        Next
                    Next
                    _tableMaintienINCINV = New Actuariat.tableMaintienINCAPINVAL(tableau_INCINV, 18, 64, nomTableMaintienINCINV)
                End If
            End Sub
            Public Function getTableMortaliteH() As tableMortalite
                Return _tableMortH
            End Function
            Public Function getTableMortaliteF() As tableMortalite
                Return _tableMortF
            End Function
            Public Function getTableMaintienINCAPINVAL() As tableMaintienINCAPINVAL
                Return _tableMaintienINCINV
            End Function
        End Class
        Public Class gestionParametreGlobal

            Protected _valeurPerso As Double
            Protected _typeCalcul As typeCalcul
            Protected _sommeBase As Double
            Protected _requeteSumBase As RequeteBDD

            Public Sub New(ByVal requeteSumBase As RequeteBDD)
                _requeteSumBase = requeteSumBase
            End Sub
            Public Property valeurPerso() As Double
                Get
                    Return _valeurPerso
                End Get
                Set(ByVal value As Double)
                    If value <> _valeurPerso Then
                        Dim e As New eventHandler(_valeurPerso, eventHandler.typeChangement.valeurPerso)
                        _valeurPerso = value
                        RaiseEvent hasChanged(Me, e)
                    End If
                End Set
            End Property
            Public Property methodeCalcul() As typeCalcul
                Get
                    Return _typeCalcul
                End Get
                Set(ByVal value As typeCalcul)
                    If value <> _typeCalcul Then
                        Dim e As New eventHandler(_typeCalcul, eventHandler.typeChangement.methodeCalcul)
                        _typeCalcul = value
                        RaiseEvent hasChanged(Me, e)
                    End If
                End Set
            End Property
            Friend ReadOnly Property sommeBase() As Double
                Get
                    Dim tbleResult As DataTable = _requeteSumBase.execute_DataTable(True)
                    Dim result As Double = 0
                    If Not tbleResult Is Nothing Then
                        result = _requeteSumBase.execute_DataTable(True).Rows(0)(0)
                    End If
                    Return result
                End Get
            End Property
            Friend Function valeurPourMoteur(ByVal valeurTraitementEntree As Double) As Double
                Dim ratio As Double = valeurTraitementEntree / sommeBase
                Dim result As Double = 0
                If methodeCalcul = typeCalcul.DepuisBase Then
                    result = valeurTraitementEntree
                Else
                    result = ratio * valeurPerso
                End If
                Return result
            End Function

            Public Enum typeCalcul
                DepuisBase
                Personnalisé
            End Enum

#Region "Gestion des évènements"
            Public Delegate Sub typeEventParametreGlobal(ByVal sender As Object, ByVal e As eventHandler)
            Public Event hasChanged As typeEventParametreGlobal
            Public Class eventHandler
                Protected _ancienneValeur As Object
                Protected _typeChangement As typeChangement
                Public Sub New(ByVal ancienneValeur As Object, ByVal typeChangement As typeChangement)
                    _ancienneValeur = ancienneValeur
                    _typeChangement = typeChangement
                End Sub
                Public ReadOnly Property ancienneValeur() As Object
                    Get
                        Return _ancienneValeur
                    End Get
                End Property
                Public ReadOnly Property changement() As typeChangement
                    Get
                        Return _typeChangement
                    End Get
                End Property
                Public Enum typeChangement
                    valeurPerso
                    methodeCalcul
                End Enum
            End Class
#End Region

        End Class
#End Region

#End Region

    End Class
#End Region

#Region "Moteur 2 - Fonctions de calcul"

    Partial Public Class Moteur_Methode2

#Region "Procédures / étapes de calcul interne"

        Private Sub calculProjectionDetailleesGen1()

            Try

                'Faire les jointures avec les paramètres déclinés pour récupérer les valeurs courantes
                Dim parametres_decl As Hashtable
                Dim parametres_uniq As Hashtable
                Dim selMedic As Double()
                parametres_decl = listeParametres.getParamDecl
                parametres_uniq = listeParametres.getParamUniq

                Dim resultatProjection As DataTable = newDataTableResultatProjections()
                Dim numSegment As Integer = 1
                Dim anneeReelleMax As Integer = 0

                For Each rowEntree As DataRow In Resultats.TableEntreeEnrichie.Rows

                    'Mise à jour des valeurs en cours des paramètres déclinés (y compris sensibilités)
                    For Each p As IParamV2 In parametres_decl.Values
                        If p.nom <> nomSel_medic Then
                            p.setValeurEnCoursAsObject(rowEntree.GetChildRows("relParam" & p.nom)(0)(p.nom))
                            rowEntree(p.nom) = rowEntree.GetChildRows("relParam" & p.nom)(0)(p.nom)
                            'Intégrer la gestion de la sélection médicale
                        Else
                            Dim result(rowEntree.GetChildRows("relParam" & p.nom).Count - 1) As Double
                            For Each rowAbattement As DataRow In rowEntree.GetChildRows("relParam" & p.nom)
                                result(parametreSelectionMedicale.nomNbAnneesDeroulement - 1) = _
                                rowAbattement(parametreSelectionMedicale.nomAbattementSelMedi)
                            Next
                            p.setValeurEnCoursAsObject(result)
                            selMedic = p.getValeurEnCoursAsObject
                        End If
                    Next

                    'Récupération des paramètres pour alimentation du moteur
                    Dim paramEntreeProj As parametreEntreeProjection = genereParamEntreeProjectionSegment(rowEntree)
                    Dim resultProjSeg As DataTable = executeProjectionSegment(paramEntreeProj)
                    Dim hasINCINV As Boolean = (rowEntree(nomIdOption) = "DC/ITT-IPT")
                    ajouteProjSegAresultatProjections(numSegment, 1, resultProjSeg, _
                                                      resultatProjection, hasINCINV, anneeReelleMax)
                    numSegment = numSegment + 1
                Next

                'Ajout du résultat détaillé de la projection globale dans les résultats
                Resultats.TableProjectionGen1Detaillee = resultatProjection.Copy
                Resultats.ProjAnneeReelleMax = anneeReelleMax + 1

            Catch ex As Exception
                MsgBox("L'erreur suivante s'est produite durant l'exécution du moteur " & ex.Message)
            End Try

        End Sub
        Private Sub calculProjectionAnuelleGen1()
            Dim resultatProjection As DataTable = Resultats.TableProjectionGen1Detaillee
            Dim anneeReelleMax As Integer = Resultats.ProjAnneeReelleMax
            'Résultats agrégés par années d'observation
            Dim resultatProjectionAgregee As projectionAnneesReelles = agregeResultatProjection(resultatProjection, _
                                                                                                anneeReelleMax, _
                                                                                                filtreGeneration, _
                                                                                                filtreSegment)
            Resultats.ProjectionGen1Annuelle = resultatProjectionAgregee
        End Sub
        Private Sub calculEmpilementGenerations()

            'Optimisation de l'algorithme de calcul
            Dim anneeRelleMax As Integer = Resultats.ProjAnneeReelleMax
            Dim projectionGen1 As projectionAnneesReelles = Resultats.ProjectionGen1Annuelle
            Dim projectionGenN As New projectionAnneesReelles

            With projectionGenN

                'OK
                .nbAnneesProj = anneeRelleMax + nbGenProj - 1
                '-2 à cause des indices qui commencent à 0
                ReDim .CSR_DC(anneeRelleMax + nbGenProj - 2)
                ReDim .Pcom_DC(anneeRelleMax + nbGenProj - 2)
                ReDim .sinReg_DC(anneeRelleMax + nbGenProj - 2)
                ReDim .PM_DCtheo(anneeRelleMax + nbGenProj - 2)
                ReDim .PCom_INCINV(anneeRelleMax + nbGenProj - 2)
                ReDim .sinRegINCINV(anneeRelleMax + nbGenProj - 2)
                ReDim .PM_INCINVtheo(anneeRelleMax + nbGenProj - 2)
                ReDim .PM_renteTheo(anneeRelleMax + nbGenProj - 2)
                ReDim .PPRC_INCINVtheo(anneeRelleMax + nbGenProj - 2)
                ReDim .MRS_Vie(anneeRelleMax + nbGenProj - 2)
                ReDim .nbCotDC(anneeRelleMax + nbGenProj - 2)
                ReDim .nbCotINCINV(anneeRelleMax + nbGenProj - 2)
                ReDim .nbSinDC(anneeRelleMax + nbGenProj - 2)
                ReDim .nbSinINCINV(anneeRelleMax + nbGenProj - 2)

                'Boucle sur les années d'observation
                For i = 1 To anneeRelleMax + nbGenProj - 1


                    'Boucle sur les générations
                    For j = Math.Max(1, i - anneeRelleMax + 1) To Math.Min(i, nbGenProj)
                        If (filtreGeneration = 0 Or filtreGeneration = j) Then
                            .CSR_DC(i - 1) = .CSR_DC(i - 1) + projectionGen1.CSR_DC(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .Pcom_DC(i - 1) = .Pcom_DC(i - 1) + projectionGen1.Pcom_DC(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .sinReg_DC(i - 1) = .sinReg_DC(i - 1) + projectionGen1.sinReg_DC(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .PM_DCtheo(i - 1) = .PM_DCtheo(i - 1) + projectionGen1.PM_DCtheo(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .PCom_INCINV(i - 1) = .PCom_INCINV(i - 1) + projectionGen1.PCom_INCINV(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .sinRegINCINV(i - 1) = .sinRegINCINV(i - 1) + projectionGen1.sinRegINCINV(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .PM_INCINVtheo(i - 1) = .PM_INCINVtheo(i - 1) + projectionGen1.PM_INCINVtheo(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .PM_renteTheo(i - 1) = .PM_renteTheo(i - 1) + projectionGen1.PM_renteTheo(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .PPRC_INCINVtheo(i - 1) = .PPRC_INCINVtheo(i - 1) + projectionGen1.PPRC_INCINVtheo(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .MRS_Vie(i - 1) = .MRS_Vie(i - 1) + projectionGen1.MRS_Vie(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)

                            .nbCotDC(i - 1) = .nbCotDC(i - 1) + projectionGen1.nbCotDC(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .nbCotINCINV(i - 1) = .nbCotINCINV(i - 1) + projectionGen1.nbCotINCINV(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .nbSinDC(i - 1) = .nbSinDC(i - 1) + projectionGen1.nbSinDC(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                            .nbSinINCINV(i - 1) = .nbSinINCINV(i - 1) + projectionGen1.nbSinINCINV(i - j) * ((1 + croissCapIni) * (1 + croissPopAssuNb)) ^ (j - 1)
                        End If
                    Next

                Next

            End With
            Resultats.ProjectionGenNAnnuelle = projectionGenN
        End Sub
        Private Sub calculComptes()

            Try
                Dim anneeReelleMax As Integer = Resultats.ProjAnneeReelleMax

                'Mise à jour des comptes
                Comptes.ModeRecalcul = typeRecalcul.SurOrdre
                'Résultats agrégés par années d'observation
                Dim resultatProjectionAgregee As projectionAnneesReelles = Resultats.ProjectionGenNAnnuelle

                Comptes.listeParametres = listeParametres
                Comptes.projectionsAnnuelles = resultatProjectionAgregee
                Comptes.nombreAnneesProjection = anneeReelleMax + nbGenProj - 1
                Comptes.Calculer()
                Resultats.compteCRTVie = Comptes.compteTechniqueVie.resultats
                Resultats.compteCRTNonVie = Comptes.compteTechniqueNonVie.resultats
                Resultats.compteCRNonTechnique = Comptes.compteNonTechnique.resultats
                Resultats.compteBesoinsFdsPropres = Comptes.compteBesoinFondsPropres.Resultats
                Resultats.compteBilan = Comptes.bilan.resultats
                Resultats.compteTresorerie = Comptes.compteTresorerie.resultats
                Resultats.compteIndicateur = Comptes.indicateur.resultats
                Comptes.ModeRecalcul = typeRecalcul.Automatique

                If TypeScenarioCalcule = TypeCalcul.ScenarioCentral Then
                    scenarioCentral.resultats.TableEntreeEnrichie = Resultats.TableEntreeEnrichie.Copy
                    scenarioCentral.resultats.ProjAnneeReelleMax = Resultats.ProjAnneeReelleMax
                    scenarioCentral.resultats.TableProjectionGen1Detaillee = Resultats.TableProjectionGen1Detaillee.Copy
                    scenarioCentral.resultats.ProjectionGen1Annuelle = Resultats.ProjectionGen1Annuelle.copy
                    scenarioCentral.resultats.ProjectionGenNAnnuelle = Resultats.ProjectionGenNAnnuelle.copy
                    scenarioCentral.resultats.compteBesoinsFdsPropres = Resultats.compteBesoinsFdsPropres.copy
                    scenarioCentral.resultats.compteCRTVie = Resultats.compteCRTVie.copy
                    scenarioCentral.resultats.compteCRTNonVie = Resultats.compteCRTNonVie.copy
                    scenarioCentral.resultats.compteCRNonTechnique = Resultats.compteCRNonTechnique.copy
                    scenarioCentral.resultats.compteBilan = Resultats.compteBilan.copy
                    scenarioCentral.resultats.compteTresorerie = Resultats.compteTresorerie.copy
                    scenarioCentral.resultats.compteIndicateur = Resultats.compteIndicateur.copy
                End If

            Catch ex As Exception
                MsgBox("L'erreur suivante s'est produite durant l'exécution du moteur " & ex.Message)
            End Try

        End Sub

        Private Sub enrichieDataTableEntree(ByVal TableEntree As DataTable)
            With TableEntree.Columns
                If Not .Contains("AGE_SOUS_AN_ACTU") Then .Add("AGE_SOUS_AN_ACTU", GetType(Double))
                If Not .Contains("nbPretsAssuMoteur") Then .Add("nbPretsAssuMoteur", GetType(Double))
                If Not .Contains(nomCapIni) Then .Add(nomCapIni, GetType(Double))
                If Not .Contains(nomTx_abat_MalaNonObje) Then .Add(nomTx_abat_MalaNonObje, GetType(Double))
                If Not .Contains(nomTx_abat_ExclPerteRev) Then .Add(nomTx_abat_ExclPerteRev, GetType(Double))
                If Not .Contains(nomAge_FinDC) Then .Add(nomAge_FinDC, GetType(Double))
                If Not .Contains(nomAge_FinINCINV) Then .Add(nomAge_FinINCINV, GetType(Double))
                If Not .Contains(nomTx_Majo_sinDCPTIA) Then .Add(nomTx_Majo_sinDCPTIA, GetType(Double))
                If Not .Contains(nomTx_MajoPrudSinINCINV) Then .Add(nomTx_MajoPrudSinINCINV, GetType(Double))
                If Not .Contains(nomTx_CommiContA) Then .Add(nomTx_CommiContA, GetType(Double))
                If Not .Contains("txEntreeINCINVmois") Then .Add("txEntreeINCINVmois", GetType(Double))
                If Not .Contains(nomTx_fraiGestA) Then .Add(nomTx_fraiGestA, GetType(Double))
                If Not .Contains("txNominalPeriode") Then .Add("txNominalPeriode", GetType(Double))
                If Not .Contains("txRembAntiPeriode") Then .Add("txRembAntiPeriode", GetType(Double))
                If Not .Contains(nomTx_TaxeAssu) Then .Add(nomTx_TaxeAssu, GetType(Double))
                If Not .Contains("txTechPeriode") Then .Add("txTechPeriode", GetType(Double))
                If Not .Contains("PCom_DC") Then .Add("PCom_DC", GetType(Double))
                If Not .Contains("PCom_INCINV") Then .Add("PCom_INCINV", GetType(Double))
                If Not .Contains("FdsPropresSurMSR") Then .Add("FdsPropresSurMSR", GetType(Double))
                If Not .Contains("prixPTIA") Then .Add("prixPTIA", GetType(Double))
                If Not .Contains("chgtSecuINCAPINVAL") Then .Add("chgtSecuINCAPINVAL", GetType(Double))
                If Not .Contains("TxRdtActifs") Then .Add("TxRdtActifs", GetType(Double))
                If Not .Contains("TxCouvEmprSub") Then .Add("TxCouvEmprSub", GetType(Double))
                If Not .Contains("TxImpoIS") Then .Add("TxImpoIS", GetType(Double))
                If Not .Contains("coutEmprSub") Then .Add("coutEmprSub", GetType(Double))
                If Not .Contains("TxRendtAttenduActionnaires") Then .Add("TxRendtAttenduActionnaires", GetType(Double))
                If Not .Contains("PresenceSelMedic") Then .Add("PresenceSelMedic", GetType(Boolean))
            End With
        End Sub
        ''' <summary>
        ''' Initialisation des paramètre nécessaires à la projection d'un segment
        ''' </summary>
        ''' <param name="tbleEntreeDataRow"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Private Function genereParamEntreeProjectionSegment(ByVal tbleEntreeDataRow As DataRow)

            'Récupération des paramètres relatifs à la ligne en cours d'étude
            Dim paramEntreeProj As New parametreEntreeProjection

            paramEntreeProj.abtMNO = listeParametres.Tx_abat_MalaNonObje.getValeurEnCours
            paramEntreeProj.abtPerteRevenus = listeParametres.Tx_abat_ExclPerteRev.getValeurEnCours
            paramEntreeProj.ageFinDC = listeParametres.Age_FinDC.getValeurEnCours
            paramEntreeProj.ageFinINCINV = listeParametres.Age_FinINCINV.getValeurEnCours
            paramEntreeProj.nbPeriode = CInt(listeParametres.Duree_Actu.getValeurEnCours)
            paramEntreeProj.majSinDC = listeParametres.Tx_Majo_sinDCPTIA.getValeurEnCours
            paramEntreeProj.majSinINCINV = listeParametres.Tx_MajoPrudSinINCINV.getValeurEnCours
            paramEntreeProj.nbInitialAssures = nbPretsAssuGen1.valeurPourMoteur(tbleEntreeDataRow.Item(nomNbPretsXassu))
            paramEntreeProj.capitalInitial = capitauxInitiaux.valeurPourMoteur(tbleEntreeDataRow.Item(nomSumCapIni))
            paramEntreeProj.txComPartenaire = listeParametres.Tx_CommiContA.getValeurEnCours
            paramEntreeProj.txEntreeINCINVmois = listeParametres.Tx_mensEntreeINCINV.getValeurEnCours
            paramEntreeProj.txFG = listeParametres.Tx_fraiGestA.getValeurEnCours
            paramEntreeProj.txNominalPeriode = mensualise_tx(listeParametres.TxNom_Actu.getValeurEnCours, typeMensualisation.tauxProportionel)
            paramEntreeProj.txRembAntiPeriode = mensualise_tx(listeParametres.Tx_RembAntiA.getValeurEnCours, typeMensualisation.tauxProportionel)
            paramEntreeProj.txTaxeINCINV = listeParametres.Tx_TaxeAssu.getValeurEnCours
            paramEntreeProj.txTechPeriode = mensualise_tx(listeParametres.Tx_TechA.getValeurEnCours, typeMensualisation.tauxEquivalent)

            Dim TEST As Double = listeParametres.Tx_TechA.getValeurEnCours

            'Les âges actuariels
            Dim qxAn As Double = tbleEntreeDataRow.GetChildRows("relParam" & nomTxMort_Actu)(0)(nomTxMort_Actu)
            Dim qxMens As Double = 1 - (1 - qxAn) ^ (1 / 12)
            Dim ageActu As Integer = IIf(tbleEntreeDataRow.Item(nomSexeAssu) = "H", _
                                         tablesDeTravail.getTableMortaliteH.ageAnMinFromQxAn(qxMens), _
                                         tablesDeTravail.getTableMortaliteF.ageAnMinFromQxAn(qxMens))
            paramEntreeProj.ageInitial = ageActu

            'Les tables de travail
            paramEntreeProj.tableMaintienINCINV = tablesDeTravail.getTableMaintienINCAPINVAL
            paramEntreeProj.tableMort = IIf(tbleEntreeDataRow.Item(nomSexeAssu) = "H", _
                                            tablesDeTravail.getTableMortaliteH, _
                                            tablesDeTravail.getTableMortaliteF)

            'La sélection médicale
            paramEntreeProj.selectionMedicale = listeParametres.Sel_medic.getValeurEnCours
            paramEntreeProj.presenceSelectionMedicale = Not (listeParametres.Sel_medic.getValeurEnCours Is Nothing)

            'Les primes commeriales ajustées des dérogations
            Dim PcomDC_nonDerogMens As Double = mensualise_tx(tbleEntreeDataRow.Item(nomPComDC_Non_Derog_Actu), typeMensualisation.tauxProportionel)
            Dim PcomDC_DerogMens As Double = mensualise_tx(tbleEntreeDataRow.Item(nomPComDC_Derog_Actu), typeMensualisation.tauxProportionel)
            Dim PourDerogDC As Double = tbleEntreeDataRow.Item(nomPourDC_Derog_Actu)
            Dim PComINCINV_nonDerogMens As Double = mensualise_tx(tbleEntreeDataRow.Item(nomPComINCINV_Non_Derog_Actu), typeMensualisation.tauxProportionel)
            Dim PComINCINV_DerogMens As Double = mensualise_tx(tbleEntreeDataRow.Item(nomPComINCINV_Derog_Actu), typeMensualisation.tauxProportionel)
            Dim PourDerogINCINV As Double = tbleEntreeDataRow.Item(nomPourINCINV_Derog_Actu)
            paramEntreeProj.tarifDCPeriode = PcomDC_nonDerogMens * (1 - PourDerogDC) + PcomDC_DerogMens * PourDerogDC
            paramEntreeProj.tarifINCINVPeriode = PComINCINV_nonDerogMens * (1 - PourDerogINCINV) + PComINCINV_DerogMens * PourDerogINCINV

            tbleEntreeDataRow(nomTx_abat_MalaNonObje) = paramEntreeProj.abtMNO
            tbleEntreeDataRow(nomTx_abat_ExclPerteRev) = paramEntreeProj.abtPerteRevenus
            tbleEntreeDataRow(nomAge_FinDC) = paramEntreeProj.ageFinDC
            tbleEntreeDataRow(nomAge_FinINCINV) = paramEntreeProj.ageFinINCINV
            tbleEntreeDataRow(nomTx_Majo_sinDCPTIA) = paramEntreeProj.majSinDC
            tbleEntreeDataRow(nomTx_MajoPrudSinINCINV) = paramEntreeProj.majSinINCINV
            tbleEntreeDataRow(nomCapIni) = paramEntreeProj.capitalInitial
            tbleEntreeDataRow(nomTx_CommiContA) = paramEntreeProj.txComPartenaire
            tbleEntreeDataRow(nomTx_fraiGestA) = paramEntreeProj.txFG
            tbleEntreeDataRow(nomTx_TaxeAssu) = paramEntreeProj.txTaxeINCINV
            tbleEntreeDataRow("txNominalPeriode") = paramEntreeProj.txNominalPeriode
            tbleEntreeDataRow("txRembAntiPeriode") = paramEntreeProj.txRembAntiPeriode
            tbleEntreeDataRow("txTechPeriode") = paramEntreeProj.txTechPeriode
            tbleEntreeDataRow("nbPretsAssuMoteur") = paramEntreeProj.nbInitialAssures
            tbleEntreeDataRow("txEntreeINCINVmois") = paramEntreeProj.txEntreeINCINVmois

            tbleEntreeDataRow("AGE_SOUS_AN_ACTU") = ageActu
            With tbleEntreeDataRow
                tbleEntreeDataRow("PCom_DC") = .Item(nomPComDC_Non_Derog_Actu) * (1 - .Item(nomPourDC_Derog_Actu)) + .Item(nomPComDC_Derog_Actu) * .Item(nomPourDC_Derog_Actu)
                tbleEntreeDataRow("PCom_INCINV") = .Item(nomPComINCINV_Non_Derog_Actu) * (1 - .Item(nomPourINCINV_Derog_Actu)) + .Item(nomPComINCINV_Derog_Actu) * .Item(nomPourINCINV_Derog_Actu)
            End With
            tbleEntreeDataRow("FdsPropresSurMSR") = listeParametres.Tx_FondPropSurMSR.getValeurEnCours
            tbleEntreeDataRow("prixPTIA") = listeParametres.Tx_PrixGarantiePTIA.getValeurEnCours
            tbleEntreeDataRow("chgtSecuINCAPINVAL") = listeParametres.Tx_chgtSecuINCINV.getValeurEnCours
            tbleEntreeDataRow("TxRdtActifs") = listeParametres.Tx_RendActifsA.getValeurEnCours
            tbleEntreeDataRow("TxCouvEmprSub") = listeParametres.Tx_CouvEmprSuboA.getValeurEnCours
            tbleEntreeDataRow("TxImpoIS") = listeParametres.Tx_TaxeImpoA.getValeurEnCours
            tbleEntreeDataRow("coutEmprSub") = listeParametres.Tx_CoutEmprSuboA.getValeurEnCours
            tbleEntreeDataRow("TxRendtAttenduActionnaires") = listeParametres.Tx_RendActionnairesA.getValeurEnCours
            tbleEntreeDataRow("PresenceSelMedic") = paramEntreeProj.presenceSelectionMedicale

            Return paramEntreeProj
        End Function
        ''' <summary>
        ''' Exécute la projection d'un segment (une fois les paramètres correctement initialisés)
        ''' </summary>
        ''' <param name="paramEntreeProj"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Private Function executeProjectionSegment(ByVal paramEntreeProj As parametreEntreeProjection) As DataTable
            _moteurEcheancier.Recalcul = typeRecalcul.SurOrdre
            _moteurEcheancier.setAbtMNO(paramEntreeProj.abtMNO)
            _moteurEcheancier.setAbtPerteRev(paramEntreeProj.abtPerteRevenus)
            _moteurEcheancier.setAgeFinDC(paramEntreeProj.ageFinDC)
            _moteurEcheancier.setAgeFinINCINV(paramEntreeProj.ageFinINCINV)
            _moteurEcheancier.setAgeInit(paramEntreeProj.ageInitial)
            _moteurEcheancier.setcapIni(paramEntreeProj.capitalInitial)
            _moteurEcheancier.setLongueurProj(paramEntreeProj.nbPeriode)
            _moteurEcheancier.setMAJsinDC(paramEntreeProj.majSinDC)
            _moteurEcheancier.setMajSinINCINV(paramEntreeProj.majSinINCINV)
            _moteurEcheancier.setNbInitAssures(paramEntreeProj.nbInitialAssures)
            _moteurEcheancier.setTableMaintienINCAPINVAL(paramEntreeProj.tableMaintienINCINV)
            _moteurEcheancier.setTableMort(paramEntreeProj.tableMort)
            _moteurEcheancier.setTarifDC(paramEntreeProj.tarifDCPeriode)
            _moteurEcheancier.setTarifINCINV(paramEntreeProj.tarifINCINVPeriode)
            _moteurEcheancier.setTxComPartenaire(paramEntreeProj.txComPartenaire)
            _moteurEcheancier.setTxEntreeINCINV(paramEntreeProj.txEntreeINCINVmois)
            _moteurEcheancier.setTxFG(paramEntreeProj.txFG)
            _moteurEcheancier.setTxNomPer(paramEntreeProj.txNominalPeriode)
            _moteurEcheancier.setTxRembAnti(paramEntreeProj.txRembAntiPeriode)
            _moteurEcheancier.setTxTaxeDC(paramEntreeProj.txTaxeINCINV)
            _moteurEcheancier.setTxTech(paramEntreeProj.txTechPeriode)
            If paramEntreeProj.presenceSelectionMedicale Then
                _moteurEcheancier.getControleurSelectionMedicale.setValeurUnique(paramEntreeProj.selectionMedicale)
            Else
                _moteurEcheancier.getControleurSelectionMedicale.setValeurUnique(Nothing)
            End If
            _moteurEcheancier.calculScenarioCentral()

            Dim result As DataTable = _moteurEcheancier.getResultats.ProjectionAnnuelle

            Return _moteurEcheancier.getResultats.ProjectionAnnuelle
        End Function
        ''' <summary>
        ''' Création de la table empilant les projections annuelles de chaque segment
        ''' </summary>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Private Function newDataTableResultatProjections() As DataTable
            Dim resultatProjectionGeneration As New DataTable
            resultatProjectionGeneration.Columns.Add("numGen", GetType(Integer))
            resultatProjectionGeneration.Columns.Add("numSegment", GetType(Integer))
            resultatProjectionGeneration.Columns.Add("anneeDeroulement", GetType(Integer))
            resultatProjectionGeneration.Columns.Add("anneeReelle", GetType(Integer))
            resultatProjectionGeneration.Columns.Add("CSRDCfin", GetType(Double))
            resultatProjectionGeneration.Columns.Add("cotisDC", GetType(Double))
            resultatProjectionGeneration.Columns.Add("sinDC", GetType(Double))
            resultatProjectionGeneration.Columns.Add("PM_DCtheo", GetType(Double))
            resultatProjectionGeneration.Columns.Add("cotisIT", GetType(Double))
            resultatProjectionGeneration.Columns.Add("sinIT", GetType(Double))
            resultatProjectionGeneration.Columns.Add("PM_Rente", GetType(Double))
            resultatProjectionGeneration.Columns.Add("PPRC", GetType(Double))
            resultatProjectionGeneration.Columns.Add("PM_ITtheo", GetType(Double))
            resultatProjectionGeneration.Columns.Add("MSR_Vie", GetType(Double))
            'Ajout des nombres de cotisants en DC et en INCAP INVAL ainsi que des nombre de sinistrés en DC et en INCAP/INVAL
            resultatProjectionGeneration.Columns.Add("nbCotDC", GetType(Double))
            resultatProjectionGeneration.Columns.Add("nbSinDC", GetType(Double))
            resultatProjectionGeneration.Columns.Add("nbCotINCINV", GetType(Double))
            resultatProjectionGeneration.Columns.Add("nbSinINCINV", GetType(Double))
            Return resultatProjectionGeneration
        End Function
        ''' <summary>
        ''' Permet d'ajouter une projection à la table résultat contenant toutes les projections des segments
        ''' </summary>
        ''' <param name="numSegment"></param>
        ''' <param name="numGeneration"></param>
        ''' <param name="resProjectionSegment"></param>
        ''' <param name="resProjection"></param>
        ''' <remarks></remarks>
        Private Sub ajouteProjSegAresultatProjections(ByVal numSegment As Integer, _
                                                      ByVal numGeneration As Integer, _
                                                      ByVal resProjectionSegment As DataTable, _
                                                      ByVal resProjection As DataTable, ByVal hasINCINV As Boolean, _
                                                      ByRef anneeReelleMax As Integer)
            For Each rowProjectionSegment As DataRow In resProjectionSegment.Rows
                Dim newRowProjection As DataRow = resProjection.NewRow()
                newRowProjection("numGen") = numGeneration
                newRowProjection("numSegment") = numSegment
                newRowProjection("anneeDeroulement") = rowProjectionSegment("numAnnee")
                newRowProjection("anneeReelle") = rowProjectionSegment("numAnnee") + numGeneration - 1
                If newRowProjection("anneeReelle") > anneeReelleMax Then anneeReelleMax = newRowProjection("anneeReelle")
                newRowProjection("CSRDCfin") = rowProjectionSegment("CSRDCfin")
                newRowProjection("cotisDC") = rowProjectionSegment("cotisDC")
                newRowProjection("sinDC") = rowProjectionSegment("sinDC")
                newRowProjection("PM_DCtheo") = rowProjectionSegment("PM_DCtheo")
                newRowProjection("cotisIT") = IIf(hasINCINV, rowProjectionSegment("cotisIT"), 0)
                newRowProjection("sinIT") = IIf(hasINCINV, rowProjectionSegment("sinIT"), 0)
                newRowProjection("PM_Rente") = IIf(hasINCINV, rowProjectionSegment("PM_Rente"), 0)
                newRowProjection("PPRC") = IIf(hasINCINV, rowProjectionSegment("PPRC"), 0)
                newRowProjection("PM_ITtheo") = IIf(hasINCINV, rowProjectionSegment("PM_ITtheo"), 0)
                newRowProjection("MSR_Vie") = rowProjectionSegment("MSR_Vie")

                newRowProjection("nbSinDC") = rowProjectionSegment("nbSinDC")
                newRowProjection("nbCotDC") = rowProjectionSegment("nbCotisants")
                newRowProjection("nbCotINCINV") = IIf(hasINCINV, rowProjectionSegment("nbCotisants"), 0)
                newRowProjection("nbSinINCINV") = IIf(hasINCINV, rowProjectionSegment("NbSinistresINCAPINVALFinPer"), 0)

                resProjection.Rows.Add(newRowProjection)
            Next
            'Dans cette méthode, il faut déterminer le nombre d'années de projection à afficher
            'Pour cela, il faut incrémenter un compteur
        End Sub
        ''' <summary>
        ''' Permet de passer de la projection mensuelle détaillée de la génération 1 à la projection annuelle
        ''' </summary>
        ''' <param name="resultatProjection"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Private Function agregeResultatProjection(ByVal resultatProjection As DataTable, _
                                                  ByVal nbAnneesProjetees As Integer, _
                                                  ByVal generation As Integer, _
                                                  ByVal segment As Integer) As projectionAnneesReelles
            Dim result As New projectionAnneesReelles
            'Faire une somme sur les années d'observation
            result.nbAnneesProj = nbAnneesProjetees
            ReDim result.CSR_DC(nbAnneesProjetees - 1)
            ReDim result.MRS_Vie(nbAnneesProjetees - 1)
            ReDim result.Pcom_DC(nbAnneesProjetees - 1)
            ReDim result.PCom_INCINV(nbAnneesProjetees - 1)
            ReDim result.PM_DCtheo(nbAnneesProjetees - 1)
            ReDim result.PM_INCINVtheo(nbAnneesProjetees - 1)
            ReDim result.PM_renteTheo(nbAnneesProjetees - 1)
            ReDim result.PPRC_INCINVtheo(nbAnneesProjetees - 1)
            ReDim result.sinReg_DC(nbAnneesProjetees - 1)
            ReDim result.sinRegINCINV(nbAnneesProjetees - 1)

            ReDim result.nbCotDC(nbAnneesProjetees - 1)
            ReDim result.nbSinDC(nbAnneesProjetees - 1)
            ReDim result.nbCotINCINV(nbAnneesProjetees - 1)
            ReDim result.nbSinINCINV(nbAnneesProjetees - 1)

            For Each r As DataRow In resultatProjection.Rows
                Dim anneeReelle As Integer = r("anneeReelle")
                Dim generationLigne As Integer = r("numGen")
                Dim segmentLigne As Integer = r("numSegment")
                If (segment = 0 Or segmentLigne = segment) Then
                    'Ajout de la fonction de filtre permettant de ne retenir que la génération ou le segment souhaité
                    result.CSR_DC(anneeReelle - 1) = result.CSR_DC(anneeReelle - 1) + r("CSRDCfin")
                    result.MRS_Vie(anneeReelle - 1) = result.MRS_Vie(anneeReelle - 1) + r("MSR_Vie")
                    result.Pcom_DC(anneeReelle - 1) = result.Pcom_DC(anneeReelle - 1) + r("cotisDC")
                    result.PCom_INCINV(anneeReelle - 1) = result.PCom_INCINV(anneeReelle - 1) + r("cotisIT")
                    result.PM_DCtheo(anneeReelle - 1) = result.PM_DCtheo(anneeReelle - 1) + r("PM_DCtheo")
                    result.PM_INCINVtheo(anneeReelle - 1) = result.PM_INCINVtheo(anneeReelle - 1) + r("PM_ITtheo")
                    result.PM_renteTheo(anneeReelle - 1) = result.PM_renteTheo(anneeReelle - 1) + r("PM_Rente")
                    result.PPRC_INCINVtheo(anneeReelle - 1) = result.PPRC_INCINVtheo(anneeReelle - 1) + r("PPRC")
                    result.sinReg_DC(anneeReelle - 1) = result.sinReg_DC(anneeReelle - 1) + r("sinDC")
                    result.sinRegINCINV(anneeReelle - 1) = result.sinRegINCINV(anneeReelle - 1) + r("sinIT")

                    result.nbSinDC(anneeReelle - 1) = result.nbSinDC(anneeReelle - 1) + r("nbSinDC")
                    result.nbCotDC(anneeReelle - 1) = result.nbCotDC(anneeReelle - 1) + r("nbCotDC")
                    result.nbSinINCINV(anneeReelle - 1) = result.nbSinINCINV(anneeReelle - 1) + r("nbSinINCINV")
                    result.nbCotINCINV(anneeReelle - 1) = result.nbCotINCINV(anneeReelle - 1) + r("nbCotINCINV")

                End If
            Next
            Return result
        End Function

#End Region

#Region "Fonctions de calcul"
        Private Class fonctionCalculMoteur2
            Inherits FonctionCalculRacine
#Region "Variables globales"
            Protected _fonctionCalculProjGen1detaillee As FonctionCalculIndividuelle
            Protected _fonctionCalculProjGen1annuelle As FonctionCalculComposee
            Protected _fonctionCalculProjGenNannuelle As FonctionCalculComposee
            Protected _fonctionCalculComptes As FonctionCalculComposee
            Protected _moteur2 As Moteur_Methode2
#End Region
#Region "Constructeur"
            Public Sub New(ByVal typeRecalcul As typeRecalcul, _
                           ByVal moteur2 As Moteur_Methode2)
                MyBase.New(PTIC_Util.typeRecalcul.SurOrdre)
                constructeurBase(moteur2)
            End Sub
            Public Sub New(ByVal typeRecalcul As typeRecalcul, _
                           ByVal moteur2 As Moteur_Methode2, _
                           ByVal etatExecRef As etatCalcul)
                MyBase.New(PTIC_Util.typeRecalcul.SurOrdre)
                '_etatCalcul = etatExecRef
                '_etatCalcul.ajouteObserver(Me)
                constructeurBase(moteur2)
            End Sub
            Public Sub constructeurBase(ByVal moteur2 As Moteur_Methode2)

                'Création des objets intervenant dans le recalcul du moteur2 et définition des dépendances
                _moteur2 = moteur2
                _fonctionCalculProjGen1detaillee = New FonctionProjGen1Detaillee( _
                                                            AddressOf moteur2.calculProjectionDetailleesGen1)
                _fonctionCalculProjGen1annuelle = New FonctionCalculComposee(PTIC_Util.typeRecalcul.SurOrdre, _
                                                            AddressOf moteur2.calculProjectionAnuelleGen1)
                _fonctionCalculProjGenNannuelle = New FonctionCalculComposee(PTIC_Util.typeRecalcul.SurOrdre, _
                                                            AddressOf moteur2.calculEmpilementGenerations)
                _fonctionCalculComptes = New FonctionCalculComposee(typeRecalcul.SurOrdre, _
                                                            AddressOf moteur2.calculComptes)

                _fonctionCalculProjGen1annuelle.AjouteFonctionCalculIntermediaire(_fonctionCalculProjGen1detaillee)
                _fonctionCalculProjGenNannuelle.AjouteFonctionCalculIntermediaire(_fonctionCalculProjGen1annuelle)
                _fonctionCalculComptes.AjouteFonctionCalculIntermediaire(_fonctionCalculProjGenNannuelle)
                Me.AjouteFonctionCalculIntermediaire(_fonctionCalculComptes)

                'Paramétrage des observations
                moteur2.ajouteObserver(Me)
                _fonctionCalculProjGen1detaillee.ajouteObserver(Me)
                _fonctionCalculProjGen1annuelle.ajouteObserver(Me)
                _fonctionCalculProjGenNannuelle.ajouteObserver(Me)
                'L'objet courant est déjà observateur des comptes car ce dernier lui est directement attaché
                ''_fonctionCalculComptes.ajouteObserver(Me)

                'Définition du mode de recalcul
                Me.ModeRecalcul = PTIC_Util.typeRecalcul.SurOrdre
            End Sub
#End Region
#Region "Propriétés"
            Public ReadOnly Property etatCalculProjGen1detaillee() As valueEtatCalcul
                Get
                    Return _fonctionCalculProjGen1detaillee.etatCalcul
                End Get
            End Property
            Public ReadOnly Property etatCalculProjGen1annuelle() As valueEtatCalcul
                Get
                    Return _fonctionCalculProjGen1annuelle.etatCalcul
                End Get
            End Property
            Public ReadOnly Property etatCalculProjGenNannuelle() As valueEtatCalcul
                Get
                    Return _fonctionCalculProjGenNannuelle.etatCalcul
                End Get
            End Property
            Public ReadOnly Property etatCalculComptes() As valueEtatCalcul
                Get
                    Return _fonctionCalculComptes.etatCalcul
                End Get
            End Property
#End Region
#Region "Actualisation"
            'La gestion des recalculs du moteur 2 est observatrice :
            '   - des recalculs constitutifs (projGen1détaillée, projGen1annuelle, projGenNannuelle)
            '   - du moteur 2 pour la modification des paramètres spécifiques
            '   - des paramètres généraux
            Public Overrides Function actualise(ByVal sender As Object, ByVal notification As Object) As PTIC_Util.resultatValidationContraintes
                MyBase.actualise(sender, notification)

                If TypeOf sender Is FonctionCalcul Then

                    Dim notif As FonctionCalcul.notification = notification

                    If notif = FonctionCalcul.notification.AvantInvalider Then
                        If sender Is _fonctionCalculProjGen1detaillee Then
                            Me.ModeRecalcul = typeRecalcul.SurOrdre
                            'Invalider le scénario central
                            If _moteur2.TypeScenarioCalcule = TypeCalcul.ScenarioCentral Then _moteur2.scenarioCentral.Invalider()
                        End If
                    End If

                End If

                If TypeOf sender Is Moteur_Methode2 Then

                    Dim notif As Moteur_Methode2.notification = notification

                    If notif = Moteur_Methode2.notification.ModifNbGenerationsProjetees Then
                        _fonctionCalculProjGenNannuelle.Invalider()

                    ElseIf notif = Moteur_Methode2.notification.ModifFiltreSegments Then
                        _fonctionCalculProjGen1annuelle.Invalider()

                    ElseIf notif = Moteur_Methode2.notification.ModifFiltreGenerations Then
                        _fonctionCalculProjGen1annuelle.Invalider()

                    ElseIf notif = Moteur_Methode2.notification.ModifCapitauxInitiaux Then
                        _fonctionCalculProjGen1detaillee.Invalider()

                    ElseIf notif = Moteur_Methode2.notification.ModifNbPretsInitiaux Then
                        _fonctionCalculProjGen1detaillee.Invalider()

                    ElseIf notif = Moteur_Methode2.notification.ModifCroissCImoyens Then
                        _fonctionCalculProjGenNannuelle.Invalider()

                    ElseIf notif = Moteur_Methode2.notification.ModifCroissNbPrets Then
                        _fonctionCalculProjGenNannuelle.Invalider()

                    ElseIf notif = Moteur_Methode2.notification.InvaliderCalculs Then
                        _fonctionCalculProjGen1detaillee.Invalider()

                    End If

                End If

                If TypeOf sender Is IParamV2 Then
                    _fonctionCalculProjGen1detaillee.Invalider()
                End If

                Return Nothing
            End Function
#End Region
        End Class
        Private Class FonctionProjGen1Detaillee
            Inherits FonctionCalculIndividuelle
            Public Sub New(ByVal Fonction As typeFonctionCalcul)
                MyBase.New(typeRecalcul.SurOrdre, Fonction)
            End Sub
            Public Overrides Sub invalider()
                Me.ModeRecalcul = typeRecalcul.SurOrdre
                MyBase.Invalider()
            End Sub
        End Class
#End Region

    End Class

#End Region

#Region "Simulations"

    ''' <summary>
    ''' La classe contenant toutes les simulations à effectuer sur le moteur 2
    ''' </summary>
    ''' <remarks></remarks>
    Public Class simulationsMoteur2
        Inherits FonctionCalculRacine

        Public Class listeSimulationsInd
            Implements IList
            Protected _lFonctionsCalcul As New List(Of IFonctionCalcul)

            Public Sub CopyTo(ByVal array As System.Array, ByVal index As Integer) Implements System.Collections.ICollection.CopyTo
                _lFonctionsCalcul.CopyTo(array, index)
            End Sub
            Public ReadOnly Property Count() As Integer Implements System.Collections.ICollection.Count
                Get
                    Return _lFonctionsCalcul.Count
                End Get
            End Property
            Private ReadOnly Property IsSynchronized() As Boolean Implements System.Collections.ICollection.IsSynchronized
                Get
                    Return True
                End Get
            End Property
            Private ReadOnly Property SyncRoot() As Object Implements System.Collections.ICollection.SyncRoot
                Get
                    Return Nothing
                End Get
            End Property
            Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
                Return _lFonctionsCalcul.GetEnumerator
            End Function
            Public Function Add(ByVal value As Object) As Integer Implements System.Collections.IList.Add
                Dim e As New listeSimulationsInd_EventArgs(value)
                _lFonctionsCalcul.Add(value)
                RaiseEvent afterAdd(Me, e)
            End Function
            Public Sub Clear() Implements System.Collections.IList.Clear
                _lFonctionsCalcul.Clear()
            End Sub
            Public Function Contains(ByVal value As Object) As Boolean Implements System.Collections.IList.Contains
                Return _lFonctionsCalcul.Contains(value)
            End Function
            Public Function IndexOf(ByVal value As Object) As Integer Implements System.Collections.IList.IndexOf
                Return _lFonctionsCalcul.IndexOf(value)
            End Function
            Public Sub Insert(ByVal index As Integer, ByVal value As Object) Implements System.Collections.IList.Insert
                _lFonctionsCalcul.Insert(index, value)
            End Sub
            Public ReadOnly Property IsFixedSize() As Boolean Implements System.Collections.IList.IsFixedSize
                Get
                    Return False
                End Get
            End Property
            Public ReadOnly Property IsReadOnly() As Boolean Implements System.Collections.IList.IsReadOnly
                Get
                    Return False
                End Get
            End Property
            Default Public Property Item(ByVal index As Integer) As Object Implements System.Collections.IList.Item
                Get
                    Return _lFonctionsCalcul.Item(index)
                End Get
                Set(ByVal value As Object)
                    _lFonctionsCalcul.Item(index) = value
                End Set
            End Property
            Public Sub Remove(ByVal value As Object) Implements System.Collections.IList.Remove
                Dim e As New listeSimulationsInd_EventArgs(value)
                Dim result As Boolean = _lFonctionsCalcul.Remove(value)
                If result Then RaiseEvent afterRemove(Me, e)
            End Sub
            Public Sub RemoveAt(ByVal index As Integer) Implements System.Collections.IList.RemoveAt
                Dim e As New listeSimulationsInd_EventArgs(Item(index))
                _lFonctionsCalcul.RemoveAt(index)
                RaiseEvent afterRemove(Me, e)
            End Sub

            Public Event afterAdd As listeSimulationsIndEventHandler
            Public Event afterRemove As listeSimulationsIndEventHandler

            Public Delegate Sub listeSimulationsIndEventHandler(ByVal sender As Object, ByVal e As listeSimulationsInd_EventArgs)
            Public Class listeSimulationsInd_EventArgs
                Inherits EventArgs
                Protected _simulation As simulationIndivMoteur2
                Public Sub New(ByVal param As simulationIndivMoteur2)
                    _simulation = param
                End Sub
                Public ReadOnly Property Simulation() As simulationIndivMoteur2
                    Get
                        Return _simulation
                    End Get
                End Property
            End Class

        End Class

        Protected _moteur As Moteur_Methode2

        Public Sub New(ByVal moteur As Moteur_Methode2)
            MyBase.New(typeRecalcul.SurOrdre)
            _lFonctionsCalculIntermediaires = New listeSimulationsInd
            AddHandler CType(_lFonctionsCalculIntermediaires, listeSimulationsInd).afterRemove, AddressOf onSimulation_Removed
            AddHandler CType(_lFonctionsCalculIntermediaires, listeSimulationsInd).afterAdd, AddressOf onSimulation_Added
            _moteur = moteur
            defaut()
        End Sub
        Public Sub defaut()

            ''AjouteFonctionCalculIntermediaire(nomTx_TechA, New simulationSensibiliteParametre(_moteur, nomTx_TechA, -0.02, 0.02, 0.004, 0.01))
            Dim simulTx_TechA As New simulationIndivMoteur2(_moteur)
            Dim paramSimulTx_TechA As New ParametreSimulationIndiv(nomTx_TechA)
            paramSimulTx_TechA.chocMin = -0.01
            paramSimulTx_TechA.ChocMax = 0.01
            paramSimulTx_TechA.Pas = 0.005
            simulTx_TechA.listeParametres.Add(paramSimulTx_TechA)
            simulTx_TechA.description = nomTx_TechA
            AjouteFonctionCalculIntermediaire(simulTx_TechA)

            Dim simulDuree_Actu As New simulationIndivMoteur2(_moteur)
            Dim paramSimulDuree_Actu As New ParametreSimulationIndiv(nomDuree_Actu)
            paramSimulDuree_Actu.chocMin = -12
            paramSimulDuree_Actu.ChocMax = 12
            paramSimulDuree_Actu.Pas = 6
            simulDuree_Actu.listeParametres.Add(paramSimulDuree_Actu)
            simulDuree_Actu.Description = nomDuree_Actu
            AjouteFonctionCalculIntermediaire(simulDuree_Actu)

            Dim simulTxNom_Actu As New simulationIndivMoteur2(_moteur)
            Dim paramTxNom_Actu As New ParametreSimulationIndiv(nomTxNom_Actu)
            paramTxNom_Actu.chocMin = -0.01
            paramTxNom_Actu.chocMax = 0.01
            paramTxNom_Actu.Pas = 0.005
            simulTxNom_Actu.listeParametres.Add(paramTxNom_Actu)
            simulTxNom_Actu.Description = nomTxNom_Actu
            AjouteFonctionCalculIntermediaire(simulTxNom_Actu)

            Dim simulTx_CommiContA As New simulationIndivMoteur2(_moteur)
            Dim paramSimulTx_CommiContA As New ParametreSimulationIndiv(nomTx_CommiContA)
            paramSimulTx_CommiContA.chocMin = -0.2
            paramSimulTx_CommiContA.chocMax = 0.2
            paramSimulTx_CommiContA.Pas = 0.05
            simulTx_CommiContA.listeParametres.Add(paramSimulTx_CommiContA)
            simulTx_CommiContA.Description = nomTx_CommiContA
            AjouteFonctionCalculIntermediaire(simulTx_CommiContA)

            Dim SimulTx_fraiGestA As New simulationIndivMoteur2(_moteur)
            Dim paramSimulTx_fraiGestA As New ParametreSimulationIndiv(nomTx_fraiGestA)
            paramSimulTx_fraiGestA.chocMin = -0.05
            paramSimulTx_fraiGestA.chocMax = 0.05
            paramSimulTx_fraiGestA.Pas = 0.01
            SimulTx_fraiGestA.listeParametres.Add(paramSimulTx_fraiGestA)
            SimulTx_fraiGestA.Description = nomTx_fraiGestA
            AjouteFonctionCalculIntermediaire(SimulTx_fraiGestA)

        End Sub

        Public Function Values() As List(Of IFonctionCalcul)
            Return ListeFonctionsCalculIntermediaires()
        End Function
        Private Sub onSimulation_Removed(ByVal sender As Object, ByVal e As listeSimulationsInd.listeSimulationsInd_EventArgs)
            Dim simulation As simulationIndivMoteur2 = CType(e.Simulation, simulationIndivMoteur2)
            simulation.retireObserver(Me)
            RaiseEvent listeSimulations_HasChanged(Me, _
                        New listeSimulationsEventArgs(simulation, _
                            listeSimulationsEventArgs.natureModifications.Suppression))
        End Sub
        Private Sub onSimulation_Added(ByVal sender As Object, ByVal e As listeSimulationsInd.listeSimulationsInd_EventArgs)
            Dim simulation As simulationIndivMoteur2 = CType(e.Simulation, simulationIndivMoteur2)
            simulation.ajouteObserver(Me)
            RaiseEvent listeSimulations_HasChanged(Me, _
            New listeSimulationsEventArgs(simulation, _
                listeSimulationsEventArgs.natureModifications.Ajout))
        End Sub
        Public Overrides Function actualise(ByVal sender As Object, ByVal notif As Object) As PTIC_Util.resultatValidationContraintes
            MyBase.actualise(sender, notif)
            If TypeOf sender Is simulationIndivMoteur2 Then
                Dim notification As FonctionCalcul.notification = notif
                If notification = FonctionCalcul.notification.ApresModifEtatCalcul Then
                    RaiseEvent listeSimulations_HasChanged(Me, _
                                    New listeSimulationsEventArgs(sender, _
                                        listeSimulationsEventArgs.natureModifications.EtatCalcul))
                End If
            End If
            Return Nothing
        End Function

        Public Overrides Sub Calculer()

            Dim debut, fin As Double
            debut = Environment.TickCount
            ''_moteur.calculeInit()

            MyBase.Calculer()

            ''_moteur.calculeCloture()
            ''MAJradar()
            'Créer un tableau synthétique à l'aide de tous les résultats correspondant aux valeurs du radar
            fin = Environment.TickCount

        End Sub
        Private Sub MAJradar()
        End Sub

        Public Event listeSimulations_HasChanged As listeSimulationsEventHandler

        Public Delegate Sub listeSimulationsEventHandler(ByVal sender As Object, ByVal notification As listeSimulationsEventArgs)
        Public Class listeSimulationsEventArgs
            Inherits EventArgs
            Protected _simulModifiee As simulationIndivMoteur2
            Protected _natureModif As natureModifications
            Public Sub New(ByVal simulationModifiee As simulationIndivMoteur2, ByVal natureModifs As natureModifications)
                _simulModifiee = simulationModifiee
                _natureModif = natureModifs
            End Sub
            Public ReadOnly Property simulModifiee() As simulationIndivMoteur2
                Get
                    Return _simulModifiee
                End Get
            End Property
            Public ReadOnly Property natureModif() As natureModifications
                Get
                    Return _natureModif
                End Get
            End Property
            Public Enum natureModifications
                Ajout
                Suppression
                EtatCalcul
                Description
            End Enum
        End Class


    End Class

    ''' <summary>
    ''' La classe représentant une simulation individuelle (qui peut être composée de plusieurs paramètres)
    ''' </summary>
    ''' <remarks></remarks>
    Public Class simulationIndivMoteur2
        Inherits CalculCompose

#Region "Variables de classe"
        Protected _temps1iterationEnS As Integer = 12
        Protected _moteur2 As Moteur_Methode2
        Protected WithEvents _lParametreSimulationIndividuelle As listeParametresSimulIndiv_IList
#End Region

#Region "Constructeur"
        Public Sub New(ByVal moteur2 As Moteur_Methode2, Optional ByVal addDefaut As Boolean = False)
            _moteur2 = moteur2
            _resultats = New DataTable
            _lParametreSimulationIndividuelle = New listeParametresSimulIndiv_IList
            'La simulation individuelle est dépendante du scénario central
            AjouteFonctionCalculIntermediaire(_moteur2.scenarioCentral)
            If addDefaut Then
                Dim paramSimulTx_Taxe As New ParametreSimulationIndiv(nomTx_TaxeAssu)
                paramSimulTx_Taxe.chocMin = 0
                paramSimulTx_Taxe.chocMax = 0
                paramSimulTx_Taxe.Pas = 0
                listeParametres.Add(paramSimulTx_Taxe)
            End If
        End Sub
#End Region

#Region "Propriété"
        Public ReadOnly Property listeParametres() As listeParametresSimulIndiv_IList
            Get
                Return _lParametreSimulationIndividuelle
            End Get
        End Property
        Public Overloads ReadOnly Property Resultats() As DataTable
            Get
                Return _resultats
            End Get
        End Property
#End Region

#Region "Gestion des paramètres de la simulation"
        Public Sub onAjoutParametre(ByVal sender As Object, ByVal e As listeParametresSimulIndiv_IList.listeParametresSimulIndiv_IList_EventArgs) Handles _lParametreSimulationIndividuelle.afterAdd
            Dim param As ParametreSimulationIndiv = e.Parametre
            Me.Invalider()
            MAJEstimationDuree()
            AddHandler param.NbIterations_HasChanged, AddressOf onNbIterations_changed
            AddHandler param.ChocMax_HasChanged, AddressOf onChocMax_hasChanged
            AddHandler param.ChocMin_HasChanged, AddressOf onChocMin_hasChanged
            AddHandler param.Pas_HasChanged, AddressOf onPas_HasChanged
        End Sub
        Public Sub onRetraitParametre(ByVal sender As Object, ByVal e As listeParametresSimulIndiv_IList.listeParametresSimulIndiv_IList_EventArgs) Handles _lParametreSimulationIndividuelle.afterRemove
            Dim param As ParametreSimulationIndiv = e.Parametre
            Me.Invalider()
            MAJEstimationDuree()
            RemoveHandler param.NbIterations_HasChanged, AddressOf onNbIterations_changed
            RemoveHandler param.ChocMax_HasChanged, AddressOf onChocMax_hasChanged
            RemoveHandler param.ChocMin_HasChanged, AddressOf onChocMin_hasChanged
            RemoveHandler param.Pas_HasChanged, AddressOf onPas_HasChanged
        End Sub
        Public Sub onNbIterations_changed(ByVal sender As Object, ByVal e As ParametreSimulationIndiv.paramSimulIndNbIterationsEventArgs)
            MAJEstimationDuree()
        End Sub
        Public Sub onChocMin_hasChanged(ByVal sender As Object, ByVal e As ParametreSimulationIndiv.paramSimulInfoChocEventArgs)
            Me.Invalider()
        End Sub
        Public Sub onChocMax_hasChanged(ByVal sender As Object, ByVal e As ParametreSimulationIndiv.paramSimulInfoChocEventArgs)
            Me.Invalider()
        End Sub
        Public Sub onPas_HasChanged(ByVal sender As Object, ByVal e As ParametreSimulationIndiv.paramSimulInfoChocEventArgs)
            Me.Invalider()
        End Sub
#End Region

#Region "Procédure de calcul de la simulation"
        Protected Overrides Sub ProcedureCalcul()
            _resultats = New DataTable
            _moteur2.TypeScenarioCalcule = Moteur_Methode2.TypeCalcul.Simulations
            For Each paramSimul As ParametreSimulationIndiv In _lParametreSimulationIndividuelle
                Resultats.Columns.Add(paramSimul.Nom, GetType(Double))
            Next
            Resultats.Columns.Add("TRI", GetType(Double))
            Resultats.Columns.Add("VAN", GetType(Double))
            Resultats.Rows.Add(Resultats.NewRow)

            _moteur2.CalculeInit()
            calculeLigneEnCours(Resultats, _lParametreSimulationIndividuelle, 0)
            Resultats.Rows.RemoveAt(Resultats.Rows.Count - 1)
            'Réinitialiser tous les simulDble
            For Each paramSimul As ParametreSimulationIndiv In _lParametreSimulationIndividuelle
                _moteur2.listeParametres.Item(paramSimul.Nom).setSimulDouble(0)
            Next

            _moteur2.CalculeCloture()
            _moteur2.TypeScenarioCalcule = Moteur_Methode2.TypeCalcul.ScenarioCentral
        End Sub
        Private Sub calculeLigneEnCours(ByRef res As DataTable, _
                                        ByVal listParametres As listeParametresSimulIndiv_IList, _
                                        ByVal indexParam As Integer)

            If indexParam <= listeParametres.Count - 1 Then
                Dim param As ParametreSimulationIndiv = listParametres(indexParam)
                For i As Double = param.chocMin To param.chocMax Step param.Pas
                    _moteur2.listeParametres.Item(param.Nom).setSimulDouble(i)
                    calculeLigneEnCours(res, listeParametres, indexParam + 1)
                Next

            Else
                _moteur2.invalideAll()
                _moteur2.Calculer()
                For Each c As DataColumn In res.Columns
                    If _moteur2.listeParametres.Keys.Contains(c.ColumnName) Then
                        res.Rows(res.Rows.Count - 1)(c.ColumnName) = _moteur2.listeParametres.Item(c.ColumnName).getSimulDble
                    End If
                Next
                res.Rows(res.Rows.Count - 1)("TRI") = _moteur2.Resultats.compteIndicateur.TRI
                res.Rows(res.Rows.Count - 1)("VAN") = _moteur2.Resultats.compteIndicateur.VAN
                res.Rows.Add(res.NewRow)

            End If

        End Sub
        Protected Sub MAJEstimationDuree()
            Dim estimationDureeCalcul As TimeSpan = New TimeSpan(0)
            Dim calculNbIterations As Integer = 0
            For Each paramSimulInd As ParametreSimulationIndiv In _lParametreSimulationIndividuelle
                If calculNbIterations = 0 Then
                    calculNbIterations = calculNbIterations + paramSimulInd.NbIterations
                Else
                    calculNbIterations = calculNbIterations * paramSimulInd.NbIterations
                End If
            Next
            _tempsCalcul = System.TimeSpan.FromSeconds(_temps1iterationEnS * calculNbIterations)
            NotifyPropertyChanged("TempsCalcul")
        End Sub
#End Region

        Public Class listeParametresSimulIndiv_IList
            Implements IList
            Protected _lParametresSimulIndiv As New List(Of ParametreSimulationIndiv)

            Public Sub CopyTo(ByVal array As System.Array, ByVal index As Integer) Implements System.Collections.ICollection.CopyTo
                _lParametresSimulIndiv.CopyTo(array, index)
            End Sub
            Public ReadOnly Property Count() As Integer Implements System.Collections.ICollection.Count
                Get
                    Return _lParametresSimulIndiv.Count
                End Get
            End Property
            Private ReadOnly Property IsSynchronized() As Boolean Implements System.Collections.ICollection.IsSynchronized
                Get
                    Return True
                End Get
            End Property
            Private ReadOnly Property SyncRoot() As Object Implements System.Collections.ICollection.SyncRoot
                Get
                    Return Nothing
                End Get
            End Property
            Public Function GetEnumerator() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
                Return _lParametresSimulIndiv.GetEnumerator
            End Function
            Public Function Add(ByVal value As Object) As Integer Implements System.Collections.IList.Add
                Dim e As New listeParametresSimulIndiv_IList_EventArgs(value)
                _lParametresSimulIndiv.Add(value)
                RaiseEvent afterAdd(Me, e)
                Return _lParametresSimulIndiv.IndexOf(value)
            End Function
            Public Sub Clear() Implements System.Collections.IList.Clear
                _lParametresSimulIndiv.Clear()
            End Sub
            Public Function Contains(ByVal value As Object) As Boolean Implements System.Collections.IList.Contains
                Return _lParametresSimulIndiv.Contains(value)
            End Function
            Public Function IndexOf(ByVal value As Object) As Integer Implements System.Collections.IList.IndexOf
                Return _lParametresSimulIndiv.IndexOf(value)
            End Function
            Public Sub Insert(ByVal index As Integer, ByVal value As Object) Implements System.Collections.IList.Insert
                _lParametresSimulIndiv.Insert(index, value)
            End Sub
            Public ReadOnly Property IsFixedSize() As Boolean Implements System.Collections.IList.IsFixedSize
                Get
                    Return False
                End Get
            End Property
            Public ReadOnly Property IsReadOnly() As Boolean Implements System.Collections.IList.IsReadOnly
                Get
                    Return False
                End Get
            End Property
            Default Public Property Item(ByVal index As Integer) As Object Implements System.Collections.IList.Item
                Get
                    Return _lParametresSimulIndiv.Item(index)
                End Get
                Set(ByVal value As Object)
                    _lParametresSimulIndiv.Item(index) = value
                End Set
            End Property
            Public Sub Remove(ByVal value As Object) Implements System.Collections.IList.Remove
                Dim e As New listeParametresSimulIndiv_IList_EventArgs(value)
                _lParametresSimulIndiv.Remove(value)
                RaiseEvent afterRemove(Me, e)
            End Sub
            Public Sub RemoveAt(ByVal index As Integer) Implements System.Collections.IList.RemoveAt
                Dim e As New listeParametresSimulIndiv_IList_EventArgs(Item(index))
                _lParametresSimulIndiv.RemoveAt(index)
                RaiseEvent afterRemove(Me, e)
            End Sub

            Public Event afterAdd As listeParametresSimulIndiv
            Public Event afterRemove As listeParametresSimulIndiv

            Public Delegate Sub listeParametresSimulIndiv(ByVal sender As Object, ByVal e As listeParametresSimulIndiv_IList_EventArgs)
            Public Class listeParametresSimulIndiv_IList_EventArgs
                Inherits EventArgs
                Protected _parametre As ParametreSimulationIndiv
                Public Sub New(ByVal param As ParametreSimulationIndiv)
                    _parametre = param
                End Sub
                Public ReadOnly Property Parametre()
                    Get
                        Return _parametre
                    End Get
                End Property
            End Class

        End Class

    End Class
    Public Class ParametreSimulationIndiv

        Protected _Nom As String
        Protected _ChocMin As Double
        Protected _ChocMax As Double
        Protected _Pas As Double
        Protected _NbIterations As Integer

        Public Sub New(ByVal nom As String)
            _Nom = nom
            _NbIterations = 1
        End Sub
        Public Sub New()
            _NbIterations = 1
        End Sub

        Public Property Nom() As String
            Get
                Return _Nom
            End Get
            Set(ByVal value As String)
                _Nom = value
            End Set
        End Property
        Public Property chocMin() As Double
            Get
                Return _ChocMin
            End Get
            Set(ByVal value As Double)
                If _ChocMin <> value Then
                    Dim e As New paramSimulInfoChocEventArgs(_ChocMin)
                    _ChocMin = value
                    RaiseEvent ChocMin_HasChanged(Me, e)
                    calculeNbIterations()
                End If
            End Set
        End Property
        Public Property chocMax() As Double
            Get
                Return _ChocMax
            End Get
            Set(ByVal value As Double)
                If _ChocMax <> value Then
                    Dim e As New paramSimulInfoChocEventArgs(_ChocMax)
                    _ChocMax = value
                    RaiseEvent ChocMax_HasChanged(Me, e)
                    calculeNbIterations()
                End If
            End Set
        End Property
        Public Property Pas() As Double
            Get
                Return _Pas
            End Get
            Set(ByVal value As Double)
                If _Pas <> value Then
                    Dim e As New paramSimulInfoChocEventArgs(_Pas)
                    _Pas = value
                    RaiseEvent Pas_HasChanged(Me, e)
                    calculeNbIterations()
                End If
            End Set
        End Property
        Public ReadOnly Property NbIterations()
            Get
                Return _NbIterations
            End Get
        End Property
        Protected Sub calculeNbIterations()
            Dim newNbIterations As Double = 0
            If _Pas <> 0 Then
                newNbIterations = Int((_ChocMax - _ChocMin) / _Pas) + 1
            Else
                If _ChocMax <> _ChocMin Then
                    newNbIterations = 2
                Else
                    newNbIterations = 1
                End If
            End If
            If _NbIterations <> newNbIterations Then
                Dim e As New paramSimulIndNbIterationsEventArgs(_NbIterations)
                _NbIterations = newNbIterations
                RaiseEvent NbIterations_HasChanged(Me, e)
            End If
        End Sub

        Public Event NbIterations_HasChanged As paramSimulIndNbIterationsEventHandler
        Public Event Pas_HasChanged As paramSimulInfoChocEventHandler
        Public Event ChocMin_HasChanged As paramSimulInfoChocEventHandler
        Public Event ChocMax_HasChanged As paramSimulInfoChocEventHandler

        Public Delegate Sub paramSimulIndNbIterationsEventHandler(ByVal sender As Object, ByVal e As paramSimulIndNbIterationsEventArgs)
        Public Delegate Sub paramSimulInfoChocEventHandler(ByVal sender As Object, ByVal e As paramSimulInfoChocEventArgs)
        Public Class paramSimulIndNbIterationsEventArgs
            Inherits EventArgs
            Protected _AncienNbIteration As Integer
            Public Sub New(ByVal AncienNbIteration As Integer)
                _AncienNbIteration = AncienNbIteration
            End Sub
            Public ReadOnly Property AncienNbIteration() As Integer
                Get
                    Return _AncienNbIteration
                End Get
            End Property
        End Class
        Public Class paramSimulInfoChocEventArgs
            Inherits EventArgs
            Protected _AncienneValeur As Double
            Public Sub New(ByVal ancienneValeur As Double)
                _AncienneValeur = ancienneValeur
            End Sub
            Public ReadOnly Property AncienneValeur() As Double
                Get
                    Return _AncienneValeur
                End Get
            End Property
        End Class

    End Class

#End Region

End Namespace
